package com.util;


import org.springframework.beans.factory.annotation.Value;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class UploadUtil {


	public static boolean uploadFile(byte[] file, String filePath, String fileName) {
		try {
			File targetFile = new File(filePath);
			if(!targetFile.exists()){
                targetFile.mkdirs();
            }
			FileOutputStream out = new FileOutputStream(filePath+fileName);
			out.write(file);
			out.flush();
			out.close();
			return true;
		} catch (IOException e) {
			e.printStackTrace();
			return false;
		}
	}
	public static void uploadFile2(byte[] file, String filePath, String fileName) throws Exception {
		File targetFile = new File(filePath);
		if(!targetFile.exists()){
			targetFile.mkdirs();
		}
		FileOutputStream out = new FileOutputStream(filePath+"/"+fileName);
		out.write(file);
		out.flush();
		out.close();
	}

}